package ch5;

import java.util.Scanner;

public class InputScore {

	public static void main(String[] args) {
		// 5人求平均
		Scanner in = new Scanner(System.in);
		int sum = 0, avg, s;
		boolean isNeg = false;
		for (int i = 1; i <= 5; i++) {
			System.out.println("请输入第" + i + "位同学的成绩：");
			s = in.nextInt();
			if (s < 0) {
				System.out.println("输入错误");
				isNeg = true;
				break;
			}
			sum += s;
		}
		if (isNeg == false) {
			avg = sum / 5;
			System.out.println("平均分为:" + avg);
		}
	}

}
